# Maintainer: Dave H <pepedog at archlinuxarm dot org>

buildarch=4

pkgname=firmware-brcm43xx
pkgdesc="wifi and bluetooth firmware for the bcm43xx"
pkgver=1.2
pkgrel=1
arch=('armv7h')
url="https://github.com/OpenBricks/openbricks/"
license=('apache' 'custom')
_commit=194b51d7f61cb05ec735c8afc9854beb692d0d6d
_url="https://raw.githubusercontent.com/OpenBricks/openbricks/$_commit/packages"
source=("$_url/firmware/firmware-wifi-brcm80211/config/bcm4329_nvram.txt"
        "$_url/firmware/firmware-wifi-brcm80211/config/bcm4330_nvram.txt"
        "$_url/net/brcm-patchram-plus/sources/bcm4329.hcd"
        "$_url/net/brcm-patchram-plus/sources/bcm4330.hcd"
        "$_url/net/brcm-patchram-plus/sources/brcm_patchram_plus.c"
        '80-brcm43xx-firmware.rules'
        'brcm43xx-firmware@.service')
md5sums=('bf01292eec17815baa68a83d3d7722ad'
         '31a9a011ce24707ed3c1024616c9005e'
         'ff27325602dc223203adfdd23a89844b'
         '8e32f9168aaa540467589c153129c57a'
         '627e9612337e5ef6027a87a79c491446'
         'b4ca6a6085eb1c2dd4560a15a178cf0e'
         '943e67bcb139d37b9b62cec0004ace88')

build() {
  gcc -Wno-error=implicit-function-declaration brcm_patchram_plus.c -o brcm_patchram_plus
}

package() {
  install -D -m0644 "${srcdir}/bcm4329_nvram.txt" "${pkgdir}/usr/lib/firmware/brcm/brcmfmac4329-sdio.txt"
  install -D -m0644 "${srcdir}/bcm4330_nvram.txt" "${pkgdir}/usr/lib/firmware/brcm/brcmfmac4330-sdio.txt"
  install -D -m0644 "${srcdir}/bcm4329.hcd" "${pkgdir}/usr/lib/firmware/brcm/bcm4329.hcd"
  install -D -m0644 "${srcdir}/bcm4330.hcd" "${pkgdir}/usr/lib/firmware/brcm/bcm4330.hcd"
  install -D -m0755 "${srcdir}/brcm_patchram_plus" "${pkgdir}/usr/bin/brcm_patchram_plus"
  install -D -m0644 "${srcdir}/80-brcm43xx-firmware.rules" "${pkgdir}/usr/lib/udev/rules.d/80-brcm43xx-firmware.rules"
  install -D -m0644 "${srcdir}/brcm43xx-firmware@.service" "${pkgdir}/usr/lib/systemd/system/brcm43xx-firmware@.service"
}
